package com.linxiangyuormdroid.example;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Author: linxiangyu
 * Date:   13-11-8
 * Time:   上午11:47
 */
public class MySQLiteHelper extends SQLiteOpenHelper {

    private static final String DATABASE_NAME = "zhang.db";
    private static final int DATABASE_VERSION = 1;
    public static final String TABLE_COMMENTS = "comments";
    public static final String COLUMN_ID = "_id";
    public static final String COLUMN_COMMENTS = "comment";


    private static final String DATABASE_CREATE = "create table " +  TABLE_COMMENTS + "(" +
            COLUMN_ID + " integer primary key autoincrement, " + COLUMN_COMMENTS + " text not null );";

    public MySQLiteHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DATABASE_CREATE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists" + TABLE_COMMENTS);
        onCreate(db);
    }
}
